<template>
  <div class="hundred_percent_form left_form">
    <el-form :label-position="labelPosition" v-loading="loading" ref="form" :model="form" label-width="100px">
      <!--<el-form-item label="微信">
        <el-input v-model="form.wxnumber" placeholder="请填写微信" clearable></el-input>
      </el-form-item>-->
        <!-- <div class="agreementBox" v-html="form.agreementcontent"></div> -->
        <tinymce style="display: inline-block;width: 60%; margin-top:2%" ref="tinymce" :height="450" v-model="form.agreementcontent"/>
        <el-form-item style="margin-top: 20px;margin-left: 40%;">
            <el-button type="primary" @click="formSubmit" :loading="formLoading">保 存</el-button>
            <!-- <el-button @click="onCancel">重置</el-button> -->
        </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {getAgreementInfo,addAgreement} from "../../api/setting/text.js";
import Tinymce from "../../components/Tinymce/index.vue";
export default {
    components: {
        Tinymce
    },

    data() {
        return {
            loading: false,
            formLoading: false,
            form: {
                text: "",
                textid: "",
                logopic: "",
                androidversion: "",
                iosversion: "",
                phone: "",
                type: 1
            },
            labelPosition: "left"
        };
    },
    methods: {
        // onCancel() {
        //     this.$router.go(0)
        //     // this.getInfo();
        // },
        getInfo() {
            this.loading = true;
            getAgreementInfo()
                .then(response => {
                    // console.info(response);
                    if (response.code) {
                        this.$message.error(response.message);
                    }
                    if (response.data) {
                        this.form = response.data;
                    }
                    setTimeout(() => {
                        this.loading = false;
                    }, 0.3 * 1000);
                })
                .catch(() => {
                    this.loading = false;
                });
        },
        formSubmit() {
            this.formLoading = true;
            let data = Object.assign({}, this.form);
            addAgreement(data).then(response => {
                this.formLoading = false;
                if (response.code) {
                    this.$message.error(response.message);
                    return false;
                }
                this.$message.success("操作成功");
                //刷新表单
                this.form = response.data;
            });
        }
    },
    created() {
        // 加载版本数据
        this.getInfo();
    }
};
</script>

<style type="text/scss" lang="scss" scoped>
body {
    margin: 0;
}
.form {
    padding: 20px;
    width: 50%;
   
}
.title {
    color: #606266;
    text-align: center;
    font-size: 18px;
    margin: 30px 0;
}
.tinymce-container{

    left: 20%;
    
}



</style>
